home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 60 / IOPROG_60.ISO / soft / c++ / gsl-1.1.1-setup.exe / {app} / src / cblas / source_symv.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-05-14  |  2.7 KB  |  94 lines

  1. /* blas/source_symv.h
  2.  * 
  3.  * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
  4.  * 
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or (at
  8.  * your option) any later version.
  9.  * 
  10.  * This program is distributed in the hope that it will be useful, but
  11.  * WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  * General Public License for more details.
  14.  * 
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  */
  19.  
  20. {
  21.   INDEX i, j;
  22.  
  23.   if (alpha == 0.0 && beta == 1.0)
  24.     return;
  25.  
  26.   /* form  y := beta*y */
  27.   if (beta == 0.0) {
  28.     INDEX iy = OFFSET(N, incY);
  29.     for (i = 0; i < N; i++) {
  30.       Y[iy] = 0.0;
  31.       iy += incY;
  32.     }
  33.   } else if (beta != 1.0) {
  34.     INDEX iy = OFFSET(N, incY);
  35.     for (i = 0; i < N; i++) {
  36.       Y[iy] *= beta;
  37.       iy += incY;
  38.     }
  39.   }
  40.  
  41.   if (alpha == 0.0)
  42.     return;
  43.  
  44.   /* form  y := alpha*A*x + y */
  45.  
  46.   if ((order == CblasRowMajor && Uplo == CblasUpper)
  47.       || (order == CblasColMajor && Uplo == CblasLower)) {
  48.     INDEX ix = OFFSET(N, incX);
  49.     INDEX iy = OFFSET(N, incY);
  50.     for (i = 0; i < N; i++) {
  51.       BASE temp1 = alpha * X[ix];
  52.       BASE temp2 = 0.0;
  53.       const INDEX j_min = i + 1;
  54.       const INDEX j_max = N;
  55.       INDEX jx = OFFSET(N, incX) + j_min * incX;
  56.       INDEX jy = OFFSET(N, incY) + j_min * incY;
  57.       Y[iy] += temp1 * A[lda * i + i];
  58.       for (j = j_min; j < j_max; j++) {
  59.     Y[jy] += temp1 * A[lda * i + j];
  60.     temp2 += X[jx] * A[lda * i + j];
  61.     jx += incX;
  62.     jy += incY;
  63.       }
  64.       Y[iy] += alpha * temp2;
  65.       ix += incX;
  66.       iy += incY;
  67.     }
  68.   } else if ((order == CblasRowMajor && Uplo == CblasLower)
  69.          || (order == CblasColMajor && Uplo == CblasUpper)) {
  70.     INDEX ix = OFFSET(N, incX) + (N - 1) * incX;
  71.     INDEX iy = OFFSET(N, incY) + (N - 1) * incY;
  72.     for (i = N; i > 0 && i--;) {
  73.       BASE temp1 = alpha * X[ix];
  74.       BASE temp2 = 0.0;
  75.       const INDEX j_min = 0;
  76.       const INDEX j_max = i;
  77.       INDEX jx = OFFSET(N, incX) + j_min * incX;
  78.       INDEX jy = OFFSET(N, incY) + j_min * incY;
  79.       Y[iy] += temp1 * A[lda * i + i];
  80.       for (j = j_min; j < j_max; j++) {
  81.     Y[jy] += temp1 * A[lda * i + j];
  82.     temp2 += X[jx] * A[lda * i + j];
  83.     jx += incX;
  84.     jy += incY;
  85.       }
  86.       Y[iy] += alpha * temp2;
  87.       ix -= incX;
  88.       iy -= incY;
  89.     }
  90.   } else {
  91.     BLAS_ERROR("unrecognized operation");
  92.   }
  93. }
  94.